package com.example.hadoopdemo1.mapper;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author cxx
 * @create 2020-02-09 10:32
 **/
public class WordCountMapper extends Mapper<LongWritable,Text,Text,LongWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String wcLine = value.toString ();
        String[] split = wcLine.split (" ");
        for (String word : split) {
            context.write (new Text (word),new LongWritable(1));
        }
    }
}
